}
+static struct file_operations xsd_kva_fops;
static struct proc_dir_entry *xsd_kva_intf;
static struct proc_dir_entry *xsd_port_intf;
+static int xsd_kva_mmap(struct file *file, struct vm_area_struct *vma)
+{
+ size_t size = vma->vm_end - vma->vm_start;
+
+ if ((size > PAGE_SIZE) || (vma->vm_pgoff != 0))
+ return -EINVAL;
+
+ vma->vm_pgoff = mfn_to_pfn(xen_start_info->store_mfn);
+
+ if (remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
+ size, vma->vm_page_prot))
+ return -EAGAIN;
+
+ return 0;
+}
static int xsd_kva_read(char *page, char **start, off_t off,
int count, int *eof, void *data)
xen_start_info->store_evtchn = op.u.alloc_unbound.port;
/* And finally publish the above info in /proc/xen */
- if((xsd_kva_intf = create_xen_proc_entry("xsd_kva", 0400)))
+ if ((xsd_kva_intf = create_xen_proc_entry("xsd_kva", 0400))) {
+ memcpy(&xsd_kva_fops, xsd_kva_intf->proc_fops,
+ sizeof(xsd_kva_fops));
+ xsd_kva_fops.mmap = xsd_kva_mmap;
+ xsd_kva_intf->proc_fops = &xsd_kva_fops;
xsd_kva_intf->read_proc = xsd_kva_read;
- if((xsd_port_intf = create_xen_proc_entry("xsd_port", 0400)))
+ }
+ if ((xsd_port_intf = create_xen_proc_entry("xsd_port", 0400)))
xsd_port_intf->read_proc = xsd_port_read;
}
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
-#include <paths.h>
//#define DEBUG
#include "utils.h"
{
int rc, fd;
evtchn_port_t port;
- unsigned long kva;
char str[20];
struct domain *dom0;
- fd = open(XENSTORED_PROC_KVA, O_RDONLY);
- if (fd == -1)
- return -1;
-
- rc = read(fd, str, sizeof(str));
- if (rc == -1)
- goto outfd;
- str[rc] = '\0';
- kva = strtoul(str, NULL, 0);
-
- close(fd);
-
fd = open(XENSTORED_PROC_PORT, O_RDONLY);
if (fd == -1)
return -1;
dom0 = new_domain(NULL, 0, port);
- fd = open(_PATH_KMEM, O_RDWR);
+ fd = open(XENSTORED_PROC_KVA, O_RDWR);
if (fd == -1)
return -1;
dom0->interface = mmap(NULL, getpagesize(), PROT_READ|PROT_WRITE,
- MAP_SHARED, fd, kva);
+ MAP_SHARED, fd, 0);
if (dom0->interface == MAP_FAILED)
goto outfd;